﻿using System.Configuration;

namespace TogNet.Configuration
{
    public class NetworkAdaptersSection : ConfigurationSection
    {
        static readonly NetworkAdaptersSection Instance = (NetworkAdaptersSection)ConfigurationManager.GetSection("NetworkAdapters");

        private NetworkAdaptersSection()
        {}

        public static NetworkAdaptersSection Settings
        {
            get
            {
                return Instance;
            }
        }

        [ConfigurationProperty("Adapters", IsRequired = true)]
        [ConfigurationCollection(typeof(NetworkAdapter))]
        public NetworkAdapterCollection Adapters
        {
            get 
            { 
                return (NetworkAdapterCollection) base["Adapters"]; 
            }
        }

        public void Save()
        {
            var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            config.Save(ConfigurationSaveMode.Full );
        }
    }
}